package com.kmvc.message.activity;

import com.kmvc.message.R;
import com.kmvc.ui.IphoneTitleBarActivity;

import android.annotation.SuppressLint;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;

public class SetUpdateRateActivity extends IphoneTitleBarActivity implements OnCheckedChangeListener{
	
	private SharedPreferences sp;
	private Editor editor;
	private RadioGroup radioGroup;
	private String[] data={"1","2","5","10","15","20","30","60"};
	private String checkedString;
	
	@SuppressLint("CommitPrefEdits")
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.set_update_rate);
		
		setTitle(R.string.updaterefsh);
	    setLeftButton(R.string.goback, null);
		
		sp = getSharedPreferences("com.kmvc.message_preferences", 0);
		editor = sp.edit();
		
		radioGroup = (RadioGroup)findViewById(R.id.radioGroup2);
		radioGroup.setOnCheckedChangeListener(this);
		
		checkedString = sp.getString("pllist", "");
		
		for(int i=0;i<8;i++){
			if(checkedString.equals(data[i])){
				radioGroup.check(i+R.id.radio11);
			}
		}
	}

	@Override
	public void onCheckedChanged(RadioGroup arg0, int i) {
		editor.putString("pllist", data[i-R.id.radio11]);
		editor.commit();
	}
}
